<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/DaoFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	/*
	* Class to select all existing requests
	*/
	class CommandSelectDepartments extends CustomCommand {
		/*
		 * Constructor of the class
		 */
		public function __construct() {
				
		}
		
		/*
		 * Method to execute to select all existing users
		 */
		public function execute() {
			$daoFactory = DaoFactory :: getMySqlDaoFactory();
			$irad = $daoFactory -> getMySqlDepartmentAccessDao();			
				$GLOBALS['debug']->log('INICIO Funcion COMANDO LISTA DE DEPARTAMENTOS');
			$sentence = $irad -> selectDepartments();
			
			$departments = ''; $i = 0;
			while ($row = mysql_fetch_array($sentence)) {
				$departments['pk_rif'][$i] = $row['pk_rif'];
				$departments['name_department'][$i] = $row['name_department'];
				$departments['name_branch'][$i++] = $row['name_branch'];
		
	
			}			
				$GLOBALS['debug']->log('FIN Funcion COMANDO LISTA DE DEPARTAMENTOS');
			$this -> result = $departments;
		}
	}
?>